//默认搜索的为资讯
var searchType = 'company';

$(function () {

    $(".Ld-header-search-hide dd").click(function () {
        var txt = $(this).text();
        $(".Ld-header-search-choose p").html(txt);
        var type = $(this).attr("id");
        switch (type) {//info文章     sjs设计师     company装修公司     ask问答      caseone效果图  casemore案例集
	        case "info":
	        	$('#searchvalue').attr('placeholder',"请输入关键词，阅读专业知识");
	            break;
	        case "company":
	        	$('#searchvalue').attr('placeholder',"请输入公司名称或关键字");
	            break;
	        case "ask":
	        	$('#searchvalue').attr('placeholder',"请输入问题，获得专业回答");
	            break;
	        case "caseone":
	        	$('#searchvalue').attr('placeholder',"请输入关键词，发现海量美图");
	            break;
	        case "casemore":
	        	$('#searchvalue').attr('placeholder',"请输入小区名称，查找案例");
	            break;  
	        case "bbs":
	        	$('#searchvalue').attr('placeholder',"请输入关键词，获取装修话题");
	            break;
        }
        
        $("#searchvalue").val("");
        $(".Ld-header-search-hide").css("display","none");
       
        changeSearchType(type);
    });

});

//改变搜索的类别
function changeSearchType(type) {
    searchType = type;
    switch (type) {
	    case "info":
	    	$('#searchvalue').attr('placeholder',"请输入关键词，阅读专业知识");
	        break;
	    case "company":
	    	$('#searchvalue').attr('placeholder',"请输入公司名称或关键字");
	        break;
	    case "ask":
	    	$('#searchvalue').attr('placeholder',"请输入问题，获得专业回答");
	        break;
	    case "caseone":
	    	$('#searchvalue').attr('placeholder',"请输入关键词，发现海量美图");
	        break;
	    case "casemore":
	    	$('#searchvalue').attr('placeholder',"请输入小区名称，查找案例");
	        break;  
	    case "bbs":
	    	$('#searchvalue').attr('placeholder',"请输入关键词，获取装修话题");
	        break;   
    }
}

//搜索跳转
function searchdata(prefix, fzprefix) {
    var keyword = $.trim($('#searchvalue').val()).replace(/[ ]/g, "");
    if (keyword == "" || keyword == null) {
        return false;
    }
    var href = "";
    switch (searchType) {//info文章     sjs设计师     company装修公司     ask问答      caseone效果图  casemore案例集
        case "info":
            href = prefix+"/Info/infoList/?keyword="+keyword;
            location.href = href;
            break;
        case "company":
        	href = fzprefix+"/gongsi/?keyword="+keyword;
        	location.href = href;
            break;
        case "ask":
        	href = prefix+"/Ask/qList/?keyword="+keyword;
        	location.href = href;
            break;
        case "caseone":
            href = prefix+"/meitu/?keyword="+keyword;
            location.href = href;
            break;
        case "casemore":
            href = fzprefix+"/anli/?keyword="+keyword;
            location.href = href;
            break; 
        case "bbs":
            href = prefix+"/bbs/search/?keyword="+keyword;
            location.href = href;
            break;  
    }
}
